//
//  KFDResponseBody.m
//  KFD
//
//  Created by JIRENTIANXIANG on 6/6/15.
//  Copyright (c) 2015 KFD. All rights reserved.
//

#import "KFDResponseBody.h"

@interface KFDResponseBody ()

@property (nonatomic,assign) BOOL success;
@property (nonatomic,assign) NSInteger status;
@property (nonatomic,assign) NSString* message;
@property (nonatomic,assign) id data;
@property (nonatomic,assign) NSNumber* time;

@end

@implementation KFDResponseBody

+(KFDResponseBody*)responseBodyWithData:(NSData *)data
{
    KFDResponseBody* responseBody=[[KFDResponseBody alloc] initWithData:data];
    return responseBody;
}

-(instancetype)initWithData:(NSData *)data
{
    if (self=[super init]) {
        NSDictionary* response=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        self.status=((NSString*)response[@"ret"]).integerValue;
        self.success=_status==0?YES:NO;
        self.message=response[@"msg"];
        self.data=response[@"data"];
        self.time=response[@"time"];
//        _log=response.description;
    }
    return self;
}

@end
